#include<bits/stdc++.h>
#define LL long long
#define F(x,s,t) for(int x=s;x<=t;x++)
using namespace std;
int read(){
	int x=0,f=1;
	char ch=getchar();
	for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	return x*f;
}
const double eps = 1e-6;
const int N = 1e5 + 10;
const int M = 1e6 + 10;
int n, m, V;//OK
int ans, cnt;//OK
vector<int> b;//OL
double L;//OK
struct Info{
	double d, v, a;//OK
	bool flg;//chao su le OK
	bool det;//bei fa xian OK
	int l, r;// OK
	vector<int> cam;//OK
}c[N];
bool p[M], cls[N];//OK
void init(int i){
	c[i].d = read();
	c[i].v = read();
	c[i].a = read();
	
	c[i].flg = 0;
	c[i].det = 0;
	c[i].cam.clear();
	
	if(c[i].a >= 0){
		if(c[i].v > V){//yi zhi chao su
			c[i].flg = 1;
			c[i].l = c[i].d;
			c[i].r = L;
		}else if(c[i].a > 0){//jia su dao chao
			double x = double(V * V - c[i].v * c[i].v) / 2 / c[i].a;
			if(c[i].d + x < double(L)){
				c[i].flg = 1;
				if(c[i].d + x - int(c[i].d + x) < eps){
					c[i].l = int(c[i].d + x) + 1;
				}else{
					c[i].l = int(c[i].d + x);
				}	
				c[i].r = L;
			}
		}	
	}else if(c[i].v > V){//jia su dao bu chao
		double x = double(V * V - c[i].v * c[i].v) / 2 / c[i].a;
		c[i].flg = 1;
		c[i].l = c[i].d;
		if(c[i].d + x > double(L)){//jian bu liao
			c[i].r = L;
		}else{
			if(c[i].d + x - int(c[i].d + x) < eps){//shi zheng shu
				c[i].r = int(c[i].d + x) - 1;
			}else{
				c[i].r = int(c[i].d + x);
			}
		}
	}	
}
void output(){
	F(i, 1, n){
		printf("%d %d %d\n", c[i].flg, c[i].l, c[i].r);
		cout<<c[i].det<<endl;
		for(int j = 0; j < int(c[i].cam.size()); j ++ ){
			cout<<c[i].cam[j]<<' ';
		}
		if(c[i].det)puts("");
	}
}
bool pd(){
	bool flg = true;
	F(i, 1, n){
		if(!c[i].det)continue;
		bool now = false;
		F(j, 0, m - 1){
			if(b[j] >= c[i].l && b[j] <= c[i].r && !cls[j]){
				now = true;
				break;
			}
		}
		if(!now){
			flg = false;
			break;
		}
	}
	return flg;
}
int main(){
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	
	int T = read();
	F(i, 1, T){
		memset(p, 0, sizeof(p));
		b.clear();
		ans = 0;
		cnt = 0;
		
		n = read(), m = read(), L = read(), V = read();
		F(i, 1, n)init(i);
		
		F(i, 1, m){
			int x = read();
			if(p[x]){ans ++; continue;}
			p[x] = 1;
			b.push_back(x);
		}
		
		//if(i != 5)continue;
		
		m = int(b.size());	
		
		F(i, 1, n){
			for(int j = 0 ;j < m; j ++ ){
				if(c[i].flg && b[j] >= c[i].l && b[j] <= c[i].r){
					c[i].det = 1;
					c[i].cam.push_back(b[j]);
				}
			}
			if(c[i].det)cnt ++;
		}
		//output();
		
		int nowans = 0;
		F(i, 0, (1 << m) - 1){
			int now = 0;
			F(j, 0, m - 1){
				cls[j] = i & (1 << j);
				//cout<<cls[j]<<' ';
				if(cls[j])now ++;//now ge bei guan diao
			}
			//puts("");
			if(now <= nowans)continue;
			if(pd())nowans = now;
		}
		
		printf("%d %d\n", cnt, ans + nowans);
	}
	return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
*/
/*
10 10 99858 982
39033 1000 -2
26456 999 -1
25617 37 -242
28141 1000 -1
27960 995 -6
1452 988 -58
44970 993 -322
16069 998 -1
26508 999 -1
44686 993 -1
1460 14938 17798 29360 42181 44971 55154 55534 74909 99858
*/
